---
import { getLanguageFromURL } from '~/util';
import { getTranslationContributors } from '~/util/getContributors';
import FacePile from './FacePile.astro';

export interface Props {
	githubRepo?: `${string}/${string}`;
}

const { githubRepo = 'withastro/docs' } = Astro.props as Props;

const lang = getLanguageFromURL(Astro.url.pathname);
const paths = [`src/content/docs/${lang}/`, `src/i18n/${lang}/`, `src/pages/${lang}/`];

// Don't fetch data for English docs
const contributors = lang === 'en' ? [] : await getTranslationContributors(paths, githubRepo);
---

{
	contributors.length !== 0 && (
		<>
			<slot />
			<FacePile {contributors} />
		</>
	)
}
